package com.icity.service.impl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.icity.entity.Application;
import com.icity.entity.EquipmentDistribution;
import com.icity.entity.EquipmentSummary;
import com.icity.entity.PartnerMsg;
import com.icity.entity.ProductType;
import com.icity.entity.RegisteredUse;
import com.icity.entity.ResourceDistribution;
import com.icity.entity.ScreenAccess;
import com.icity.entity.ScreenTraffic;
import com.icity.entity.StatisticalSummary;
import com.icity.entity.journalBookReadBorrow;
import com.icity.entity.journalBookStatistical;
import com.icity.mapper.EquipmentSummaryMapper;
import com.icity.mapper.StatisticalSummaryMapper;
import com.icity.service.EquipmentSummaryService;
import com.icity.service.StatisticalSummaryService;
import com.icity.util.DateUtils;

@Service
@Transactional
public class EquipmentSummaryServiceImpl implements EquipmentSummaryService{
	@Autowired
	private EquipmentSummaryMapper equipmentSummaryMapper;
	@Override
	public List<EquipmentSummary> getAllEquimentSummary(Map<Object, Object> map){
		
		return equipmentSummaryMapper.getAllEquimentSummary(map);
	}
	
	@Override
	public List<ProductType> getProductTypeOverview(Map<Object, Object> map){
		
		return equipmentSummaryMapper.getProductTypeOverview(map);
	}
	
	
	@Override
	public List<ScreenAccess> getAllScreenAnalysis(Map<Object, Object> map){
		
		return equipmentSummaryMapper.getAllScreenAnalysis(map);
	}

	@Override
	public List<ScreenTraffic> getAllScreenAnalysisPie(Map<Object, Object> map){
		
		
		 String  datetype= String.valueOf(map.get("datetype"));
			List<ScreenTraffic> list=null;
		  if (datetype.equals("1")) {
				Date date = new Date();
				SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
				String specifiedDay = sdf.format(date);
				String end_time=DateUtils.getSpecifiedDayBefore(specifiedDay,7);
				String statrt_time=specifiedDay;
				map.put(end_time, "end_time");
				map.put(statrt_time, "statrt_time");
				list = equipmentSummaryMapper.getAllScreenAnalysisPie(map);
				}else if(datetype.equals("2")) {
					Date date = new Date();
					SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
					String specifiedDay = sdf.format(date);
					String end_time=DateUtils.getSpecifiedDayBefore(specifiedDay,14);
					String statrt_time=specifiedDay;
					map.put(end_time, "end_time");
					map.put(statrt_time, "statrt_time");
					list = equipmentSummaryMapper.getAllScreenAnalysisPie(map);
				}else if(datetype.equals("3")) {
					
					Date date = new Date();
					SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
					String specifiedDay = sdf.format(date);
					String end_time=DateUtils.getSpecifiedDayBefore(specifiedDay,30);
					String statrt_time=specifiedDay;
					map.put(end_time, "end_time");
					map.put(statrt_time, "statrt_time");
					list = equipmentSummaryMapper.getAllScreenAnalysisPie(map);
				}else{
					Date date = new Date();
					SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
					String specifiedDay = sdf.format(date);
					String end_time=DateUtils.getSpecifiedDayBefore(specifiedDay,7);
					String statrt_time=specifiedDay;
					map.put(end_time, "end_time");
					map.put(statrt_time, "statrt_time");
					list = equipmentSummaryMapper.getAllScreenAnalysisPie(map);
					
				}			 			
		
		
		
		
		
		return list;
	}
   
}
